#!/bin/bash

rm -f book_store
rm -f docker/book_store.tar.gz
if [ $? -eq 0 ];
then
    echo "docker/book_store.tar.gz is removed ---> successfully"
else
    echo "!!!!! remove docker/book_store.tar.gz ---> failed !!!!!"
    exit 1
fi

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o book_store
if [ $? -eq 0 ];
then
    echo "go build ---> successfully"
else
    echo "!!!!! go build ---> failed !!!!!"
    exit 1
fi

tar -acvf book_store.tar.gz book_store config/config.yml file/

mv book_store.tar.gz docker/
cd docker/

tDate=$(date '+%Y%m%d%H%M%S')

docker build ./ -t jibin0310/book_store:"$tDate"
# docker buildx build ./ -t jibin0310/book_store:"$tDate" --platform=linux/amd64